﻿using System;
using System.Web.Mvc;

namespace BrettM.Web.Restful
{

    /// <summary>
    /// The Restful Attribute is used to decorate a method in a controller and exposing the method with a restful service
    /// </summary>
    public class RestfulAttribute
        : Attribute
    {
        /// <summary>
        /// Defines a string from the virtual path root that identifies the resource being exposed.
        /// </summary>
        /// <remarks>
        /// The url must conform to standard routes as used with System.Web.Routing and can contain
        /// parameters, optional parameters.
        /// </remarks>
        public string Url { get; private set; }
        
        
        /// <summary>
        /// The http method the route on the Url subscribes to.
        /// </summary>
        /// <remarks>
        /// 
        /// <list type="bullet">
        /// <item>Head</item>
        /// <item>Get</item>
        /// <item>Put</item>
        /// <item>Post</item>
        /// <item>Delete</item>
        /// </list>
        /// </remarks>
        public HttpVerbs HttpVerb { get; private set; }

        /// <summary>
        /// An object that describes the constraints to be placed on the route
        /// </summary>
        public Type ConstraintType { get; set; }

        /// <summary>
        /// The ctor used to when decorating a controller method.
        /// </summary>
        /// <param name="url">The url that exposes the resource.</param>
        /// <param name="httpVerb">The http method the route on the Url subscribes to.</param>
        public RestfulAttribute(string url, HttpVerbs httpVerb)
        {
            Url = url;
            HttpVerb = httpVerb;
        }
    }
}
